package com.xuecheng.order.dao;

import com.xuecheng.framework.domain.task.XcTask;
import io.swagger.models.auth.In;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.Date;

public interface XcTaskRepository extends JpaRepository<XcTask, String> {
    Page<XcTask> findByUpdateTimeBefore(Pageable pageable, Date date);

    //    更新数据库版本号k
    @Modifying
    @Query("update XcTask t set t.version= :version+1 where t.id= :id and t.version= :version")
    int updateVersion(@Param(value = "id") String id, @Param(value = "version") Integer version);
}
